package interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 鑷畾涔夋嫤鎴櫒
 * @author Steven
 *
 */
public class MyInterceptor implements HandlerInterceptor {

	//方法执行之后
	//处理异常 清理资源 记录日志等等
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		System.out.println("MyInterceptor.afterCompletion.......");
	}

	//方法执行之后，返回ModelAndView之前
	//设置页面的共用参数等等
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		System.out.println("MyInterceptor.postHandle.......");
	}

	//进入方法前被调用
	//登陆拦截，权限校验等待
	@Override
	public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
		System.out.println("MyInterceptor.preHandle.......");
		//true鏀捐,false鎷︽埅
		return true;
	}

}
